home *** CD-ROM | disk | FTP | other *** search
- Path: kai.com!not-for-mail
- From: robison@kai.com (Arch Robison)
- Newsgroups: comp.object,comp.lang.eiffel,comp.lang.c++,comp.lang.beta,comp.lang.java,comp.lang.sather
- Subject: Re: What Should An Exception Handling Do? -- Clarification of rules
- Date: 28 Mar 1996 10:39:09 -0600
- Organization: Kuck & Associates, Inc.
- Message-ID: <4jefbd$k33@kai.com>
- References: <4j954n$mrq@kai.com> <1996Mar27.211117.5569@schbbs.mot.com>
- NNTP-Posting-Host: kai.com
-
- In article <1996Mar27.211117.5569@schbbs.mot.com> shang@corp.mot.com writes:
- >If resumption semantics were inferior, why should we bother to get
- >its "benefits" by simulating its semantics as below:
-
- I should have qualified my statement "inferior" to "inferior in most cases".
-
- >> bool retry;
- >> do {
- >> retry = false;
- >> try {
- >> result = do_something();
- >> }
- >> catch( condition1 ) {some_extraordinary_work1(); retry=true;}
- >> catch( condition2 ) {some_extraordinary_work2(); retry=true;}
- >> catch( condition3 ) {some_extraordinary_work3(); retry=true;}
- >> catch( condition4 ) {result=NULL;}
- >> } while( retry );
- >>
- >
- >How do you define these conditions? They must be in different types,
- >I assume, otherwise C++ cannot locate the cather.
- >
- >What happen if we forget to inialize "retry"? Okay, we can use break, but
- >what happen if we have nested exceptions? "Goto" must be used, I guess.
- >Busy jumps around are no fun.
- >
- >What happen if we forget to set "result" to NULL under condition4?
-
- What if I forget to increment my loop variables? What if I use single
- precision where I should have used double precision? What if I misunderstood
- the problem specification? What if my disk drive explodes today?
- For any programming problem X, I can build a complete solution to X
- into the language (or hardware). FORTRAN solves the loop problem
- with a do-loop form. Infinite-precision arithmetic solves problems too,
- but at run-time cost. Endless meetings and documents (according to some
- theories) solve specification problems. And I can encase my machine in a
- steel case to protect me from explosions. But sometimes I judge that the
- cost of doing so is not worth the likely benefit.
-
- The original attack on C++ unfairly implied that the C++ committee had given no
- though to the issues. As described in Stroustrup's D&E book, the C++ committee
- knowledgeably debated the resumption vs. termination models of exception
- handling and judged that the extra cost of the resumption model was not worth
- the cost in added complexity. There is no such thing as a feature
- that "you do not pay for it if you do not use it." Each feature that is
- implemented subtracts time from implementing or refining other features.
- I am employed implementing the optimizer for a high-performance C++ compiler,
- so I speak from experience.
-
- Thus many apparently useful features are deliberately left out of C++ .
- Users who want the features can simulate them without burdening others.
- Besides, for some of these features, even the users who want them
- disagree about the precise semantics, so it is often better to let
- the users simulate the feature so that they can define the semantics they want.
-
- C++ is not intended to be the best language for all problems.
- If another language is better for your problem, use it.
-
- Arch D. Robison Kuck & Associates Inc.
- robison@kai.com 1906 Fox Drive
- 217-356-2288 Champaign IL 61820
-